import { useEffect, useState } from "react";
import { request } from "../utils/request";

export function useRequest(url, method) {
  const [data, setData] = useState();

  useEffect(() => {
    request({
      url,
      method,
    }).then((resp) => {
      setData(resp.data.data);
    });
  }, []);

  return { data };
}
